# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Kilian Guillaume "cafehaine" <kilian dot guillaume at gmail dot com>

pkgbase=lua-std-normalize
_rockname=${pkgbase#lua-}
pkgname=("$pkgbase" "lua51-$_rockname" "lua52-$_rockname" "lua53-$_rockname")
_pkgname=normalize
pkgver=2.0.3
_rockrel=1
pkgrel=6
pkgdesc='Lua-stdlib project’s normalized lua functions library'
arch=(any)
url="https://github.com/lua-stdlib/$_pkgname"
license=(MIT)
_luadeps=(std-debug)
makedepends=(lua
             lua51
             lua52
             lua53
             luarocks)
# checkdepends=(specl)
_archive="${_rockname#std-}-$pkgver"
source=("$url/archive/v$pkgver/$_archive.tar.gz")
sha256sums=('2038c38da542cf274b0b7512928e5b649c90a34f36c8919fbbbc2524b4ef716d')

_package() {
	cd "$_archive"
	depends=("${pkgname%%-*}" "${_luadeps[@]/#/${pkgname%%-*}-}")
	luarocks --lua-version="$1" --tree="$pkgdir/usr/" \
		make --deps-mode=none --no-manifest "${_rockname/-/.}-$pkgver-$_rockrel.rockspec"
	install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE.md
}

package_lua-std-normalize() {
	_package 5.4
}

package_lua51-std-normalize() {
	_package 5.1
}

package_lua52-std-normalize() {
	_package 5.2
}

package_lua53-std-normalize() {
	_package 5.3
}
